package com.block.common.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.block.common.constant.AppRspCodeConstant;
import com.block.common.constant.SysConstant;
import com.block.common.service.ISysConstantInfoService;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.SysConstantInfo;
import com.block.db.mapper.SysConstantInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2022-08-20
 */
@Service
public class SysConstantInfoServiceImpl extends ServiceImpl<SysConstantInfoMapper, SysConstantInfo> implements ISysConstantInfoService {

    @Autowired
    StringRedisTemplate stringRedisTemplate;

    @Override
    public ResponseVo getAppConfigInfo() {
        SysConstantInfo constantInfo = this.baseMapper.getEntryByType(SysConstant.TYPE_APP_CONFIG_INFO);
        JSONObject jsonObject = JSON.parseObject(constantInfo.getValue());
        return new ResponseVo(AppRspCodeConstant.SUCCESS, jsonObject);
    }

    @Override
    public ResponseVo getNoticeList() {
        SysConstantInfo constantInfo = this.baseMapper.getEntryByType(SysConstant.TYPE_NOTICE_LIST);
        JSONArray jsonArray = JSON.parseArray(constantInfo.getValue());

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("dataList", jsonArray);

        return new ResponseVo(AppRspCodeConstant.SUCCESS, jsonObject);
    }

}
